home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / unix / c / utime < prev    next >
Text File  |  1996-11-09  |  1KB  |  62 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/utime,v $
  4.  * $Date: 1996/10/30 22:04:51 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: utime,v $
  10.  * Revision 1.2  1996/10/30 22:04:51  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.1  1996/04/19 21:35:27  simon
  14.  * Initial revision
  15.  *
  16.  ***************************************************************************/
  17.  
  18. static const char rcs_id[] = "$Id: utime,v 1.2 1996/10/30 22:04:51 unixlib Rel $";
  19.  
  20. #include <errno.h>
  21. #include <time.h>
  22. #include <unistd.h>
  23. #include <utime.h>
  24. #include <sys/os.h>
  25.  
  26. int
  27. utime (const char *filename, const struct utimbuf *times)
  28. {
  29.   int r[6];
  30.   char *file;
  31.   _kernel_oserror *e;
  32.   time_t t;
  33.  
  34.   file = __uname ((char *)filename, 0);
  35.  
  36.   if (e = os_file (0x05, file, r))
  37.     {
  38.       __seterr (e);
  39.       return -1;
  40.     }
  41.   if (!r[0])
  42.     {
  43.       errno = ENOENT;
  44.       return -1;
  45.     }
  46.  
  47.   /* If times is null then get the current time.  */
  48.   t = (times) ? times->modtime : time (0);
  49.  
  50.   r[2] = (r[2] & 0x000fff00U) | 0xfff00000U |
  51.     ((((t >> 8) * 100) >> 24) + 0x33);
  52.   r[3] = t * 100 + 0x6e996a00U;
  53.  
  54.   if (e = os_file (0x01, file, r))
  55.     {
  56.       __seterr (e);
  57.       return -1;
  58.     }
  59.  
  60.   return 0;
  61. }
  62.